1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gobject.SignalGroup; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gobject.c.functions; 32 public import gobject.c.types; 33 private import std.algorithm; 34 35 36 /** 37 * #GSignalGroup manages to simplify the process of connecting 38 * many signals to a #GObject as a group. As such there is no API 39 * to disconnect a signal from the group. 40 * 41 * In particular, this allows you to: 42 * 43 * - Change the target instance, which automatically causes disconnection 44 * of the signals from the old instance and connecting to the new instance. 45 * - Block and unblock signals as a group 46 * - Ensuring that blocked state transfers across target instances. 47 * 48 * One place you might want to use such a structure is with #GtkTextView and 49 * #GtkTextBuffer. Often times, you'll need to connect to many signals on 50 * #GtkTextBuffer from a #GtkTextView subclass. This allows you to create a 51 * signal group during instance construction, simply bind the 52 * #GtkTextView:buffer property to #GSignalGroup:target and connect 53 * all the signals you need. When the #GtkTextView:buffer property changes 54 * all of the signals will be transitioned correctly. 55 * 56 * Since: 2.72 57 */ 58 public class SignalGroup : ObjectG 59 { 60 /** the main Gtk struct */ 61 protected GSignalGroup* gSignalGroup; 62 63 /** Get the main Gtk struct */ 64 public GSignalGroup* getSignalGroupStruct(bool transferOwnership = false) 65 { 66 if (transferOwnership) 67 ownedRef = false; 68 return gSignalGroup; 69 } 70 71 /** the main Gtk struct as a void* */ 72 protected override void* getStruct() 73 { 74 return cast(void*)gSignalGroup; 75 } 76 77 /** 78 * Sets our main struct and passes it to the parent class. 79 */ 80 public this (GSignalGroup* gSignalGroup, bool ownedRef = false) 81 { 82 this.gSignalGroup = gSignalGroup; 83 super(cast(GObject*)gSignalGroup, ownedRef); 84 } 85 86 87 /** */ 88 public static GType getType() 89 { 90 return g_signal_group_get_type(); 91 } 92 93 /** 94 * Creates a new #GSignalGroup for target instances of @target_type. 95 * 96 * Params: 97 * targetType = the #GType of the target instance. 98 * 99 * Returns: a new #GSignalGroup 100 * 101 * Since: 2.72 102 * 103 * Throws: ConstructionException GTK+ fails to create the object. 104 */ 105 public this(GType targetType) 106 { 107 auto __p = g_signal_group_new(targetType); 108 109 if(__p is null) 110 { 111 throw new ConstructionException("null returned by new"); 112 } 113 114 this(cast(GSignalGroup*) __p, true); 115 } 116 117 /** 118 * Blocks all signal handlers managed by @self so they will not 119 * be called during any signal emissions. Must be unblocked exactly 120 * the same number of times it has been blocked to become active again. 121 * 122 * This blocked state will be kept across changes of the target instance. 123 * 124 * Since: 2.72 125 */ 126 public void block() 127 { 128 g_signal_group_block(gSignalGroup); 129 } 130 131 /** 132 * Connects @c_handler to the signal @detailed_signal 133 * on the target instance of @self. 134 * 135 * You cannot connect a signal handler after #GSignalGroup:target has been set. 136 * 137 * Params: 138 * detailedSignal = a string of the form "signal-name::detail" 139 * cHandler = the #GCallback to connect 140 * data = the data to pass to @c_handler calls 141 * 142 * Since: 2.72 143 */ 144 public void connect(string detailedSignal, GCallback cHandler, void* data) 145 { 146 g_signal_group_connect(gSignalGroup, Str.toStringz(detailedSignal), cHandler, data); 147 } 148 149 /** 150 * Connects @c_handler to the signal @detailed_signal 151 * on the target instance of @self. 152 * 153 * The @c_handler will be called after the default handler of the signal. 154 * 155 * You cannot connect a signal handler after #GSignalGroup:target has been set. 156 * 157 * Params: 158 * detailedSignal = a string of the form "signal-name::detail" 159 * cHandler = the #GCallback to connect 160 * data = the data to pass to @c_handler calls 161 * 162 * Since: 2.72 163 */ 164 public void connectAfter(string detailedSignal, GCallback cHandler, void* data) 165 { 166 g_signal_group_connect_after(gSignalGroup, Str.toStringz(detailedSignal), cHandler, data); 167 } 168 169 /** 170 * Connects @c_handler to the signal @detailed_signal 171 * on the target instance of @self. 172 * 173 * You cannot connect a signal handler after #GSignalGroup:target has been set. 174 * 175 * Params: 176 * detailedSignal = a string of the form "signal-name::detail" 177 * cHandler = the #GCallback to connect 178 * data = the data to pass to @c_handler calls 179 * notify = function to be called when disposing of @self 180 * flags = the flags used to create the signal connection 181 * 182 * Since: 2.72 183 */ 184 public void connectData(string detailedSignal, GCallback cHandler, void* data, GClosureNotify notify, GConnectFlags flags) 185 { 186 g_signal_group_connect_data(gSignalGroup, Str.toStringz(detailedSignal), cHandler, data, notify, flags); 187 } 188 189 /** 190 * Connects @c_handler to the signal @detailed_signal on #GSignalGroup:target. 191 * 192 * Ensures that the @object stays alive during the call to @c_handler 193 * by temporarily adding a reference count. When the @object is destroyed 194 * the signal handler will automatically be removed. 195 * 196 * You cannot connect a signal handler after #GSignalGroup:target has been set. 197 * 198 * Params: 199 * detailedSignal = a string of the form `signal-name` with optional `::signal-detail` 200 * cHandler = the #GCallback to connect 201 * object = the #GObject to pass as data to @c_handler calls 202 * flags = #GConnectFlags for the signal connection 203 * 204 * Since: 2.72 205 */ 206 public void connectObject(string detailedSignal, GCallback cHandler, void* object, GConnectFlags flags) 207 { 208 g_signal_group_connect_object(gSignalGroup, Str.toStringz(detailedSignal), cHandler, object, flags); 209 } 210 211 /** 212 * Connects @c_handler to the signal @detailed_signal 213 * on the target instance of @self. 214 * 215 * The instance on which the signal is emitted and @data 216 * will be swapped when calling @c_handler. 217 * 218 * You cannot connect a signal handler after #GSignalGroup:target has been set. 219 * 220 * Params: 221 * detailedSignal = a string of the form "signal-name::detail" 222 * cHandler = the #GCallback to connect 223 * data = the data to pass to @c_handler calls 224 * 225 * Since: 2.72 226 */ 227 public void connectSwapped(string detailedSignal, GCallback cHandler, void* data) 228 { 229 g_signal_group_connect_swapped(gSignalGroup, Str.toStringz(detailedSignal), cHandler, data); 230 } 231 232 /** 233 * Gets the target instance used when connecting signals. 234 * 235 * Returns: The target instance 236 * 237 * Since: 2.72 238 */ 239 public ObjectG dupTarget() 240 { 241 auto __p = g_signal_group_dup_target(gSignalGroup); 242 243 if(__p is null) 244 { 245 return null; 246 } 247 248 return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p, true); 249 } 250 251 /** 252 * Sets the target instance used when connecting signals. Any signal 253 * that has been registered with g_signal_group_connect_object() or 254 * similar functions will be connected to this object. 255 * 256 * If the target instance was previously set, signals will be 257 * disconnected from that object prior to connecting to @target. 258 * 259 * Params: 260 * target = The target instance used 261 * when connecting signals. 262 * 263 * Since: 2.72 264 */ 265 public void setTarget(ObjectG target) 266 { 267 g_signal_group_set_target(gSignalGroup, (target is null) ? null : target.getObjectGStruct()); 268 } 269 270 /** 271 * Unblocks all signal handlers managed by @self so they will be 272 * called again during any signal emissions unless it is blocked 273 * again. Must be unblocked exactly the same number of times it 274 * has been blocked to become active again. 275 * 276 * Since: 2.72 277 */ 278 public void unblock() 279 { 280 g_signal_group_unblock(gSignalGroup); 281 } 282 283 /** 284 * This signal is emitted when #GSignalGroup:target is set to a new value 285 * other than %NULL. It is similar to #GObject::notify on `target` except it 286 * will not emit when #GSignalGroup:target is %NULL and also allows for 287 * receiving the #GObject without a data-race. 288 * 289 * Params: 290 * instance_ = a #GObject containing the new value for #GSignalGroup:target 291 * 292 * Since: 2.72 293 */ 294 gulong addOnBind(void delegate(ObjectG, SignalGroup) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 295 { 296 return Signals.connect(this, "bind", dlg, connectFlags ^ ConnectFlags.SWAPPED); 297 } 298 299 /** 300 * This signal is emitted when the target instance of @self is set to a 301 * new #GObject. 302 * 303 * This signal will only be emitted if the previous target of @self is 304 * non-%NULL. 305 * 306 * Since: 2.72 307 */ 308 gulong addOnUnbind(void delegate(SignalGroup) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 309 { 310 return Signals.connect(this, "unbind", dlg, connectFlags ^ ConnectFlags.SWAPPED); 311 } 312 }